<template>
  <div>
     <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-row>
          <el-col :span="8">
             <el-input
              placeholder="请输入内容"
              prefix-icon="el-icon-search"
              clearable
              v-model="searchInput">
            </el-input>
          </el-col>
          <el-col :span="2"><el-button plain @click="getMainData(index,count)">查询</el-button></el-col>
          <el-col :span="2" :offset="12" v-if="userType=='0'">
             <el-button type="primary" @click="dialogVisible = true">新增<i class="el-icon-plus el-icon--right"></i></el-button>
          </el-col>
        </el-row>
       
      </div>
      
      <div>
        <el-table
          ref="multipleTable"
          :data="realData"
          tooltip-effect="dark"
          style="width: 100%"
          @selection-change="handleSelectionChange">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>

          <el-table-column
            label="名称"
            width="120">
            <template slot-scope="scope">{{ scope.row.KJMC }}</template>
          </el-table-column>

          <!-- <el-table-column
            label="课件"
            width="220">
            <template slot-scope="scope">
               <img :src="scope.row.FM" @click="openvideo(scope.row.KJLJ)"  alt="" style="width: 220px;height:180px">
            </template>
          </el-table-column> -->

           <el-table-column
            label="封面"
            width="250">
           <template slot-scope="scope">
              <img v-if="scope.row.KJFM" :src="scope.row.KJFM" style="width: 220px;height:160px">
           </template>
          </el-table-column>

          <el-table-column
            label="介绍">
            <template slot-scope="scope" class="limit2">
              <div class="limit2">{{ scope.row.KJJS }}</div>
            </template>
          </el-table-column>

          <el-table-column
            label="老师"
            width="120">
            <template slot-scope="scope">{{ scope.row.KJZZ }}</template>
          </el-table-column>
         
           <el-table-column
            label="操作"
            width="300">
            <template slot-scope="scope">
              <el-button @click="handleSendJMS(scope.row)" type="text" size="small" v-if="userType=='0'">发送给加盟商</el-button>
              <el-button @click="handleSend(scope.row)" type="text" size="small" v-if="userType=='0'">发送给加盟商组</el-button>
              <el-button @click="handleEdit(scope.row)" type="text" size="small" v-if="userType=='0'">编辑</el-button>
              <el-button @click="handledelete(scope.row)" type="text" size="small" v-if="userType=='0'">删除</el-button>
              <el-button @click="handledownload(scope.row)" type="text" size="small">下载</el-button>
            </template>
          </el-table-column>
        </el-table>

        <div class="block mt-3">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage3"
            :page-size="count"
            layout="prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>

      </div>

      

    </el-card>

    <!-- 添加结盟商的弹出界面 -->
    <el-dialog
      title="课件新增"
      :visible.sync="dialogVisible"
      width="80%"
      :before-close="handleClose">
       <div class="add">
      <el-form :label-position="labelPosition" label-width="100px" :model="formLabelAlign">
        <el-form-item label="名称">
          <el-input  v-model="formLabelAlign.MC" placeholder="请输入课件名称"></el-input>
        </el-form-item>

        <el-form-item label="介绍">
          <el-input v-model="formLabelAlign.JS" placeholder="请输入课件介绍"></el-input>
        </el-form-item>

         <el-form-item label="上传封面图片">
           <el-row>
              <el-col :span="4">
                <el-upload
                  class="avatar-uploader"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :http-request="savePicture"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :on-change = "onchange"
                  :before-upload="beforeAvatarUpload">
                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon imgBorder"></i>
                </el-upload>
              </el-col>
            </el-row> 
        </el-form-item>

        <el-form-item label="老师">
          <el-input v-model="formLabelAlign.LS" placeholder="请输入老师名称"></el-input>
        </el-form-item>
       

       <el-form-item label="上传课件">
          <el-row>
            <el-col :span="4">
              <el-upload
                class="upload-demo"
                action="https://jsonplaceholder.typicode.com/posts/"
                :http-request="saveVideo"
                :before-upload="beforeUpload2"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="1"
                :on-exceed="handleExceed">
                <el-button size="small" type="primary">点击上传</el-button>
                <div class="progressUp">
                  <el-progress v-if="percentage>0" :percentage="percentage"></el-progress>
                </div>
              </el-upload>
            </el-col>
          </el-row> 
        </el-form-item>

         <el-form-item label="上传时间">
            <el-row>
              <el-col :span="4">
                <div class="block">
                  <el-date-picker
                    v-model="today"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd">
                  </el-date-picker>
                </div>
              </el-col>
            </el-row> 
          </el-form-item>

      </el-form>
    </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false;handleCancle()">取 消</el-button>
        <el-button type="primary" @click="franchiseesAdd()">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 编辑的界面 -->
    <el-dialog
      title="课件编辑"
      :visible.sync="dialogVisible_Edit"
      width="80%"
      :before-close="handleClose">
      <el-form :label-position="labelPosition" label-width="100px" :model="editData">
        <el-form-item label="名称">
          <el-input  v-model="editData.KJMC" placeholder="请输入课件名称"></el-input>
        </el-form-item>

        <el-form-item label="介绍">
          <el-input v-model="editData.KJJS" placeholder="请输入课件介绍"></el-input>
        </el-form-item>

        <el-form-item label="上传封面图片">
          <el-row>
            <el-col :span="4">
              <el-upload
                class="avatar-uploader"
                action="https://jsonplaceholder.typicode.com/posts/"
                :http-request="savePicture"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :on-change = "onchange"
                :before-upload="beforeAvatarUpload">
                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon imgBorder"></i>
              </el-upload>
            </el-col>
          </el-row>

          <!-- 
            <el-row>
              <el-col :span="4">
                
              </el-col>
            </el-row> 
          -->
          
        </el-form-item>

        <el-form-item label="老师">
          <el-input v-model="editData.KJZZ" placeholder="请输入老师名称"></el-input>
        </el-form-item>

        <el-form-item label="上传时间">
           <el-row>
            <el-col :span="4">
               <div class="block">
                <el-date-picker
                  v-model="today"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd">
                </el-date-picker>
              </div>
            </el-col>
          </el-row> 
        </el-form-item>
       
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible_Edit = false">取 消</el-button>
        <el-button type="primary" @click="franchiseesEdit()">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 查看的页面 -->
    <el-dialog
      title="课件详情"
      :visible.sync="dialogVisible_look"
      width="40%"
      :before-close="handleClose">
      <el-card class="box-card">
        <el-row>
          <el-col :span="8">手机号 :</el-col>
          <el-col :span="8">{{lookData.SJHM}}</el-col>
        </el-row>
        <el-row>
          <el-col :span="8">名称 :</el-col>
          <el-col :span="8">{{lookData.XSMC}}</el-col>
        </el-row>
        <el-row>
          <el-col :span="8">介绍 :</el-col>
          <el-col :span="8">{{lookData.JJ}}</el-col>
        </el-row>
        <el-row>
          <el-col :span="8">地址 :</el-col>
          <el-col :span="8">{{lookData.XXDZ}}</el-col>
        </el-row>
        <el-row>
          <el-col :span="8">图片 :</el-col>
          <el-col :span="8">
            <img v-if="lookData.TXTP" :src="lookData.TXTP" width="100px" height="100px">
          </el-col>
        </el-row>
      </el-card>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible_look = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible_look = false">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog style="background:none;" :fullscreen="true" :destroy-on-close="true" :visible.sync="dialogVideoVisible" >
        <video width="80%" height="80%" controls>
            <source :src="videosrc" type="video/mp4">
        </video>
    </el-dialog>


 </div>
</template>


<script>
import axios from 'axios'
export default {
    data() {
      return {
        userType:1,
        realData:[],
        multipleSelection: [],
        //课件播放
        dialogVideoVisible: false,
        videosrc: "",
        //添加界面弹出层参数 
        dialogVisible: false,
        //编辑界面弹出层参数
        dialogVisible_Edit:false,
        //查看界面弹出层参数
        dialogVisible_look:false,
        //添加课件参数
        labelPosition: 'left',
        formLabelAlign: {
          MC: '',//名称
          JS:'',//介绍
          LS:'',//老师
          // FM //封面。需要调用后获取
          // LJ //课件文件地址。调用后获取
        },
        //上传图片模块必须要定义的参数
        imageUrl:'',
        videoImageUrl:'',
        fileArr:[],
        videoArr:[],
        uid:'',  // 存储在本地的uid
        editData:{
          OBJID:'', //uid 
          XWBT:'', // 课件标题
          XWFBT:'', // 课件副标题
          XWNR:'', //课件内容  
          FMTP:'' //封面图片
        },
        lookData:{
          CJR: '',
          CJSJ: '',
          JJ: '',
          OBJID: '',
          SJHM: '',
          TXTP: '',
          XSMC: '',
          XXDZ: '',
          YHLX: ''
        },
        searchInput:'',//查询
        currentPage3: 1,//当前页面，默认初始化为1
        total:100,    //分页总数
        index:0,  //自定义获取数据参数
        count:3,  // 分页长度（每页展示的数据数量） 
        coverUrl:'',//课件封面地址
        percentage:0, //上传课件进度条 ,
        OBJID:'',//编辑
        fileList:[],//显示课件
        today:''
      }
    },

    methods: {
      /* 课件分发给 加盟商 组 */
      handleSend(row){
        console.log(row);
        this.$router.push({name:'courseSend',params:{row:row,fflx:1}});
      },
      /* 课件分发给 加盟商 */
      handleSendJMS(row){
        console.log(row);
        this.$router.push({name:'courseSend2',params:{row:row,fflx:0}});
      },
      /* 课件下载 */
      handledownload(row) {
        // console.log(row);
        window.location.href = row.KJLJ
      },
      /* 课件播放 */
      openvideo(src) {
          this.videosrc = src;
          this.dialogVideoVisible = true;
      },
      /* 分页 */
      handleSizeChange(val) {
        // console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.getMainData((val-1)*this.count,this.count)
      },
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      // 查看
      handleClick(row){
        // console.log(row);
        this.lookData = row
        this.dialogVisible_look = true
      },
      //课件信息编辑
      handleEdit(row){
        // console.log(row);
        this.editData = row
        this.imageUrl = this.editData.KJFM
        console.log(this.editData);
        this.dialogVisible_Edit = true
        this.OBJID = row.OBJID
        this.today = row.KJRQ
      },

      /* 课件新增 */
      async franchiseesAdd(row){

        var data = this.formLabelAlign

        if(data.MC==''){
          this.$message({
            message: '名称不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }

        if(data.JS==''){
          this.$message({
            message: '介绍不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }

        if(this.videoArr.length==0){
          this.$message({
            message: '课件不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }

        if(this.imageUrl==''){
          this.$message({
            message: '课件封面不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }



        if(this.fileArr.length>0){
          this.$message({
            message: "开始上传",
            type: 'warning',
            duration:1000
          });
          this.upload(this.fileArr[this.fileArr.length-1])
        }
        
      },
      //添加结盟商成功后 或 取消添加时  =>  清空form数据 
      clearFormAddData(){
        var that = this
        that.formLabelAlign.MC=''
        that.formLabelAlign.JS=''
        that.imageUrl=''
        that.formLabelAlign.LS=''
        var date = new Date();
        that.today= date.getFullYear()+'-'+date .getMonth()+'-'+date .getDate()
        that.videoArr = []
      },

      /* 弹出层关闭前  （X号关闭）*/
      handleClose(done) {
        done();
        this.clearFormAddData()
      },
      handleCancle(){
       this.clearFormAddData()
      },
      /* 上传头像 */
      handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
      },
      onchange(file){
        // console.log(file);      
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
          return
        }
         this.handleAvatarSuccess(file,file)
      },
      beforeAvatarUpload(file) {
        // const isJPG = file.type === 'image/jpeg';
        const isJPG = true;
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      },
      /*自定义存储图片，点击上传后调用 upload(param) 上传 */
      savePicture(req){
        this.fileArr.push(req.file)
      },

      /* ————————  上传课件 ————————  开始 */
      beforeUpload2(file){
        this.videoArr.push(file)
      },
      handleRemove(file, fileList) {
        var videoArr = this.videoArr.filter(t=>t.name!=file.name)  
        this.videoArr = videoArr
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        console.log(fileList);
        // this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
        this.$message.warning('你只能上传一个课件文件');
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
      saveVideo(){
        console.log(this.videoArr);
      },
      
      /* —————————— 上传课件 ————————— 结束 */

      /* 上传图片自定义事件 */
      upload(file){
        var that = this    

        var file = file; // 对象，上传的文件
        var fileExtension = (file.name).split('.').pop();
        var key = this.$md5(file.name)+"."+fileExtension; // 文件资源名
        /*
        * config.useCdnDomain: 是否使用 cdn 加速域名，true or false，默认为 false。
        * config.disableStatisticsReport: 是否禁用日志报告，为布尔值，默认为false。
        * config.region: 选择上传域名区域；当为 null 或 undefined 时，自动分析上传域名区域
        * config.retryCount: 上传自动重试次数（整体重试次数）；默认3次（即上传失败后最多重试两次）；
        * config.concurrentRequestLimit: 分片上传的并发请求量，number，默认为3；
        * config.checkByMD5: 是否开启 MD5 校验，在断点续传时校验分片，默认为 false，不开启。
        */
        let config = {
            useCdnDomain: true, 
            region: this.$qiniu.region.z0
        };

        /*
        * fname: string，文件原文件名.
        * params: object，用来放置自定义变量;
        * mimeType: null || array，用来限制上传文件类型，为 null 时表示不对文件类型限制；
        * 限制类型放到数组里： ["image/png", "image/jpeg", "image/gif"]
        */
        let putExtra = {
            fname: file,
            params: {}, 
            mimeType: ["image/png", "image/jpeg", "image/gif"]
        };
        let observe = {
            next (res) {
                console.log('已上传大小，单位为字节：' + res.total.loaded)
                console.log('本次上传的总量控制信息，单位为字节：' + res.total.size)
                console.log('当前上传进度，范围：0～100：' + res.total.percent);
            },
          error (err) {
                console.log(err.code)
                console.log(err.message)
                console.log(err.isRequestError)
                console.log(err.reqId)
            },
            complete (res) {
                //完成后的操作
                //上传成功以后会返回key 和 hash  key就是文件名了！
                console.log(res)
                console.log('http://img.lingdongzhe.com/'+res.key);
                
                 console.log(that.formLabelAlign);
               
               that.coverUrl = 'http://img.lingdongzhe.com/'+res.key

               if(that.OBJID!=''){
                  var params = {}
                  params.ACTIONNAME = 'saveKj';

                  params.uid = that.uid;
                  params.objid = that.OBJID;
                  params.KJRQ = that.today; //7时间
                  
                  var data =  that.editData
                  params.KJMC = data.MC; //2名称 ok
                  params.KJJS = data.JS; //4介绍 ok
                  params.KJZZ = data.LS; //6作者
                  params.KJFM = that.coverUrl; //5封面

                  that.$get(params).then(res => {
                    console.log(res)
                    if(res.SUCCESS){
                      that.$message({
                        message: res.MSG,
                        type: 'success',
                        duration:1000
                      });
                      that.getMainData(that.index,that.count)
                      that.clearFormAddData()
                      that.dialogVisible_Edit = false
                      that.percentage=0
                      that.OBJID=''
                    }else{
                      that.$message({
                        message: res.MSG,
                        type: 'warning',
                        duration:1000
                      });
                      that.dialogVisible_Edit = false
                    }
                  })
                  return
               }

                if(that.videoArr.length>0){
                  that.uploadVideo(that.videoArr[0])
                }
            }
        };

        var params2 = {}
        params2.ACTIONNAME = 'getQiniutoken'
        params2.uid = that.uid;
        this.$get(params2).then(res => {
          var upToken =  res.DATA
          console.log('upToken : '+upToken);
          //开始上传  token 需要找后端获取(单独的方法)
          let observable = this.$qiniu.upload(file, key, upToken, putExtra, config)
          let subscription = observable.subscribe(observe)
        })
        
        // //开始上传  token 需要找后端获取(单独的方法)
        // let observable = this.$qiniu.upload(file, key, upToken, putExtra, config)
        // let subscription = observable.subscribe(observe)
      },

      /* 上传完图片再上传课件  */
      uploadVideo(file){
        var that = this    

        var file = file; // 对象，上传的文件
        var fileExtension = (file.name).split('.').pop();
        var key = this.$md5(file.name)+"."+fileExtension; // 文件资源名
        /*
        * config.useCdnDomain: 是否使用 cdn 加速域名，true or false，默认为 false。
        * config.disableStatisticsReport: 是否禁用日志报告，为布尔值，默认为false。
        * config.region: 选择上传域名区域；当为 null 或 undefined 时，自动分析上传域名区域
        * config.retryCount: 上传自动重试次数（整体重试次数）；默认3次（即上传失败后最多重试两次）；
        * config.concurrentRequestLimit: 分片上传的并发请求量，number，默认为3；
        * config.checkByMD5: 是否开启 MD5 校验，在断点续传时校验分片，默认为 false，不开启。
        */
        let config = {
            useCdnDomain: true, 
            region: this.$qiniu.region.z0
        };

        /*
        * fname: string，文件原文件名.
        * params: object，用来放置自定义变量;
        * mimeType: null || array，用来限制上传文件类型，为 null 时表示不对文件类型限制；
        * 限制类型放到数组里： ["image/png", "image/jpeg", "image/gif"]
        */
        let putExtra = {
            fname: file,
            params: {}, 
            // mimeType: ["image/png", "image/jpeg", "image/gif"]
        };
        let observe = {
            next (res) {
                console.log('已上传大小，单位为字节：' + res.total.loaded)
                console.log('本次上传的总量控制信息，单位为字节：' + res.total.size)
                console.log('当前上传进度，范围：0～100：' + res.total.percent);
                that.percentage = Math.round(res.total.percent)
            },
          error (err) {
                console.log(err.code)
                console.log(err.message)
                console.log(err.isRequestError)
                console.log(err.reqId)
            },
            complete (res) {
                //完成后的操作
                //上传成功以后会返回key 和 hash  key就是文件名了！
                console.log(res)
                console.log('http://img.lingdongzhe.com/'+res.key);
                
                console.log('图片地址'+that.coverUrl); //图片地址

                 console.log(that.formLabelAlign);
                // var data =  that.formLabelAlign

                var params = {}
                params.ACTIONNAME = 'saveKj';

                params.uid = that.uid;//1
                params.KJRQ = that.today; //7时间
                
                var data =  that.formLabelAlign
                params.KJMC = data.MC; //2名称 ok
                params.KJJS = data.JS; //4介绍 ok
                params.KJZZ = data.LS; //6作者
                params.KJFM = that.coverUrl; //5封面
                params.KJLJ = 'http://img.lingdongzhe.com/'+res.key //3课件地址

                that.$get(params).then(res => {
                  console.log(res)
                  if(res.SUCCESS){
                     that.$message({
                      message: res.MSG,
                      type: 'success',
                      duration:1000
                    });
                    that.getMainData(that.index,that.count)
                    that.clearFormAddData()
                    that.dialogVisible = false
                    that.percentage=0
                    that.OBJID=''
                  }else{
                    that.$message({
                      message: res.MSG,
                      type: 'warning',
                      duration:1000
                    });
                  }
                })

            }
        };

        var params2 = {}
        params2.ACTIONNAME = 'getQiniutoken'
        params2.uid = that.uid;
        this.$get(params2).then(res => {
          var upToken =  res.DATA
          console.log('upToken : '+upToken);
          //开始上传  token 需要找后端获取(单独的方法)
          let observable = this.$qiniu.upload(file, key, upToken, putExtra, config)
          let subscription = observable.subscribe(observe)
        })
        
      },
      /* 课件编辑 */
       franchiseesEdit(){
        var data = this.editData
        console.log(data);

        if(data.MC==''){
          this.$message({
            message: '名称不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }

        if(data.JS==''){
          this.$message({
            message: '介绍不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }

        if(this.imageUrl==''){
          this.$message({
            message: '课件封面不能为空',
            type: 'warning',
            duration:1000
          });
          return
        }
        

        if(this.fileArr.length>0){
          this.upload(this.fileArr[this.fileArr.length-1])
        }else{ 
            var that = this
            var params = {}
            params.ACTIONNAME = 'saveKj';

            params.uid = that.uid;
            params.objid = that.OBJID;
            params.KJRQ = that.today; //7时间
            
            var data =  that.editData
            params.KJMC = data.KJMC; //2名称 ok
            params.KJJS = data.KJJS; //4介绍 ok
            params.KJZZ = data.KJZZ; //6作者
            params.KJFM = this.imageUrl; //5封面

            that.$get(params).then(res => {
              console.log(res)
              if(res.SUCCESS){
                that.$message({
                  message: res.MSG,
                  type: 'success',
                  duration:1000
                });
                that.getMainData(that.index,that.count)
                that.clearFormAddData()
                that.dialogVisible_Edit = false
                that.percentage=0
                that.OBJID=''
              }else{
                that.$message({
                  message: res.MSG,
                  type: 'warning',
                  duration:1000
                });
                that.dialogVisible_Edit = false
              }
            })

        }
      },
      handledelete(row){
        var that = this
        console.log(row);
        that.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var params = {}
          params.ACTIONNAME = 'delKj';

          console.log(localStorage.token);
          console.log(row.OBJID);
          
          params.uid = localStorage.token;
          params.objid = row.OBJID;
          
          this.$get(params).then(res => {
            if(res.SUCCESS){
                that.$message({
                message: res.MSG,
                type: 'success',
                duration:1000
              });
                that.getMainData(that.index,that.count)
            }else{
              that.$message({
                message: res.MSG,
                type: 'warning',
                duration:1000
              });
            }
          })
        })
        
      },
      /* 获取上传七牛云token，与本身token无关 */
      getToken(){
        var params2 = {}
        params2.ACTIONNAME = 'getQiniutoken';
        params2.uid = '0';
        this.$get(params2).then(res => {
          this.upToken =  res.DATA
        })
      },
      /* 获取主数据，第一次进入页面加载的数据 */
      async getMainData(index,count){
        
        var params = {}
        params.ACTIONNAME = 'getKjList1';
        params.index = index;
        params.count = count;
        params.uid = this.uid;
        params.flag = 0;
        params.keywords = this.searchInput;
        params.yearandmonth=''
        this.$get(params).then(res => {
          // window.console.log(res)
          console.log(res)
          if(res.SUCCESS){
            this.realData = res.DATA.LIST
             this.total = res.DATA.TOTAL;
          }
        })
      },
    },
    created(){
      this.userType = localStorage.userType

      this.uid = localStorage.uid
      this.getMainData(this.index,this.count)
      var date = new Date();
      this.today = date.getFullYear()+'-'+date .getMonth()+'-'+date .getDate()
    }
  }
</script>

<style scoped>
 .text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.el-table{
  width: 600px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both
}
/* 头像 */
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  .avatar-uploader-icon[data-v-3f78ccf2] {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border: 1px solid #DCDFE6;
}

.el-form-item{
  position: relative;
}
.tip{
    color: #9d0b0b;
    position: absolute;
    right: 1%;
    top: 0;
}

.el-row {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin: 20px 0;
}
.progressUp{
  width: 200px;
  margin-top: 10px;
  margin-left: 10%;
}
</style>